﻿using QuiddichWPF.Config;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace QuiddichWPF
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void cups_Clicked(object sender,RoutedEventArgs args)
        {
            CupWindow cpWindow = new CupWindow();
            cpWindow.Show();
        }

        private void buttonPlayers_MouseClick(object sender, RoutedEventArgs e)
        {
            PlayerWindow plWindow = new PlayerWindow();
            plWindow.Show();
        }

        private void buttonMatches_MouseClick(object sender, RoutedEventArgs e)
        {
            MatchWindow mtWindow = new MatchWindow();
            mtWindow.Show();
        }

        private void buttonTeams_MouseClick(object sender, RoutedEventArgs e)
        {
            TeamWindow tm = new TeamWindow();
            tm.Show();
        }

        private void buttonStadiums_MouseClick(object sender, RoutedEventArgs e)
        {
            StadiumWindow stWindow = new StadiumWindow();
            stWindow.Show();
        }

        private void buttonReservations_MouseClick(object sender, RoutedEventArgs e)
        {
            ReservationWindow rsWindow = new ReservationWindow();
            rsWindow.Show();
        }

        /// <summary>
        /// Déclenché lors du clic sur la fenêtre principale afin de pouvoir la déplacer
        /// </summary>
        /// <param name="sender"> Sender object </param>
        /// <param name="e"> Arguments </param>
        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
             if (e.LeftButton == MouseButtonState.Pressed)
                this.DragMove();
        }

        /// <summary>
        /// Sauvegarde des préférences lors de la fermeture de la fenêtre
        /// </summary>
        /// <param name="sender"> Sender object </param>
        /// <param name="e"> Arguments </param>
        private void mainWin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Configuration.ConfigurationUtility.RegisterWindowConfig(Window.GetWindow(this));
        }

        /// <summary>
        /// Chargement des préférences et configuration de la fenêtre
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mainWin_Initialized(object sender, EventArgs e)
        {
            Configuration.ConfigurationUtility.Configure(Window.GetWindow(this));
        }
    }
}
